package com.lagou.service.impl;

import com.lagou.service.TestService;
import org.apache.dubbo.config.annotation.Service;

import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;

/**
 * @author xsl
 * @date 2021/5/21 18:37
 * @Description: TestServiceImpl
 */
@Service
public class TestServiceImpl implements TestService {
    @Override
    public String methodA() {
        sleepRandomTimeout();
        return "method A";
    }

    @Override
    public String methodB() {
        sleepRandomTimeout();
        return "method B";
    }

    @Override
    public String methodC() {
        sleepRandomTimeout();
        return "method C";
    }

    public void sleepRandomTimeout() {
        final long timeout = ThreadLocalRandom.current().nextLong(100L);
//        System.out.println("================================timeout:" + timeout);
        try {
            TimeUnit.MILLISECONDS.sleep(timeout);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
